<form method="GET" action="<?php echo site_url('search/cari/') ?>">
    <div class="page cariproperti">
        <div class="container">
            <div class="row">
                <div class="span4 perincianpencarian">
                    <div class="span3 title">
                        <h4>Perincian Pencarian</h4>
                    </div>
                    <div class="row jual-beli">
                        <div class="span1">     
                            <label class="radio">
                                <input type="radio" name="mode" id="optionsRadios1"
                                       value="1" data-toggle="radio"
                                       <?php
                                       if ($this->input->get('mode', TRUE) == 1)
                                           echo "checked=''"
                                           ?>>
                                Jual
                            </label>
                        </div>
                        <div class="span1">
                            <label class="radio">
                                <input type="radio" name="mode" id="optionsRadios2"
                                       value="2" data-toggle="radio"
                                       <?php
                                       if ($this->input->get('mode', TRUE) == 2)
                                           echo "checked=''"
                                           ?>>
                                Sewa
                            </label>
                        </div>
                    </div>
                    <div class="span3">
                        <select name="tipe" value="0" class="select-block span3">
                            <option value="" selected>
                                -- Tipe Properti --
                            </option>
                            <?php
                            $i = 1;
                            foreach ($tipe->result() as $value) {
                                echo "<option value='" . $i . "'";
                                if ($this->input->get('tipe', TRUE) == $i) {
                                    echo "selected";
                                }
                                $i++;
                                echo ">";
                                echo $value->nama;
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="area" value="Villa" class="select-block span3">
                            <option value="0" selected>
                                -- Area --
                            </option>
                            <?php
                            $i = 1;
                            foreach ($area->result() as $value) {
                                if ($this->input->get('area', TRUE) == $i) {
                                    echo "<option value='" . $i++ . "' selected>";
                                } else {
                                    echo "<option value='" . $i++ . "'>";
                                }
                                echo $value->kota_kab;
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="tidur" value="Villa" class="select-block span3">
                            <option value="" selected="selected">
                                -- Kamar Tidur --
                            </option>
                            <?php
                            $i = 1;
                            while ($i < 10) {
                                echo "<option value='" . $i . "'";
                                if ($this->input->get('tidur', TRUE) == $i) {
                                    echo "selected";
                                }
                                echo ">";
                                echo $i++;
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="mandi" value="Villa" class="select-block span3">
                            <option value="" selected="selected">
                                -- Kamar Mandi --
                            </option>
                            <?php
                            $i = 1;
                            while ($i < 10) {
                                echo "<option value='" . $i . "'";
                                if ($this->input->get('mandi', TRUE) == $i) {
                                    echo "selected";
                                }
                                echo ">";
                                echo $i++;
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="luasmin" value="Villa" class="select-block span3">
                            <option value="0" selected="selected">
                                -- Luas Minimum --
                            </option>
                            <?php
                            $i = 1;
                            while ($i < 10) {
                                echo "<option value='" . $i . "00'";
                                if ($this->input->get('luasmin', TRUE) == ($i . "00")) {
                                    echo "selected";
                                }
                                echo ">";
                                echo $i++ . "00 meter persegi";
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="luasmaks" value="Villa" class="select-block span3">
                            <option value="9999" selected="selected">
                                -- Luas Maksimum --
                            </option>
                            <?php
                            $i = 1;
                            while ($i < 10) {
                                echo "<option value='" . $i . "000'";
                                if ($this->input->get('luasmaks', TRUE) == ($i . "000")) {
                                    echo "selected";
                                }
                                echo ">";
                                echo $i++ . "000 meter persegi";
                                echo "</option>";
                            }
                            ?>
                        </select>

                    </div>
                    <div class="span3">
                        <select name="hargamin" value="Villa" class="select-block span3">
                            <option value="0" selected="selected">
                                -- Harga Minimum --
                            </option>
                            <?php
                            $i = 1;
                            while ($i < 10) {
                                echo "<option value='" . $i . "00000000' ";
                                if ($this->input->get('hargamin', TRUE) == ($i . "00000000")) {
                                    echo "selected";
                                }
                                echo ">";
                                echo "Rp. " . $i++ . "00 juta";
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="hargamaks" value="Villa" class="select-block span3">
                            <option value="1000000000000" selected="selected">
                                -- Harga Maksimum --
                            </option>
                            <?php
                            $i = 1;
                            while ($i < 10) {
                                echo "<option value='" . $i . "000000000' ";
                                if ($this->input->get('hargamaks', TRUE) == ($i . "000000000")) {
                                    echo "selected";
                                }
                                echo ">";
                                echo "Rp. " . $i++ . " Milyar";
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        <select name="sertifikat" value="Villa" class="select-block span3">
                            <option value="" selected="selected">
                                -- Sertifikat --
                            </option>
                            <?php
                            $i = 1;
                            foreach ($sertifikat->result() as $value) {
                                echo "<option value='" . $i++ . "'";
                                if ($this->input->get('sertifikat', TRUE) == $i) {
                                    echo "selected";
                                }
                                echo ">";
                                echo $value->nama_sertifikat;
                                echo "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div class="span3">
                        Kata Kunci :
                        <input type="text" value="<?php echo $search; ?>" name="search" class="span3" />
                    </div>
                    <div class="span2 submitpencarian">
                        <input type="submit" value="CARI" class="btn btn-large btn-block btn-primary submitpencarian" />
                    </div>

                </div>
                <div class="span8">
                    <?php
                        if (count($result) > 0) {?>
                    <h2>Daftar Properti</h2>
                    <div class="span8 daftarproperti">
                        <?php
                        $bulan = array(
                            "01" => "Jan",
                            "02" => "Feb",
                            "03" => "Mar",
                            "04" => "Apr",
                            "05" => "Mei",
                            "06" => "Jun",
                            "07" => "Jul",
                            "08" => "Aug",
                            "09" => "Sept",
                            "10" => "Okt",
                            "11" => "Nov",
                            "12" => "Des"
                        );
                        ?>
                        <div class="row">
                            <div class="span5 urutanberdasarkan">
                                Urutkan Berdasarkan:
                                <select name="urutan" value="urutan" class="select-block span2"
                                        onchange="this.form.submit()">
                                    <option value="1"
                                    <?php
                                    if ($this->input->get('urutan', TRUE) == "1")
                                        echo "selected";
                                    ?>        
                                            >Listing Terbaru</option>
                                    <option value="2"
                                    <?php
                                    if ($this->input->get('urutan', TRUE) == "2")
                                        echo "selected";
                                    ?>       
                                            >Listing Terpopuler</option>
                                    <option value="3"
                                    <?php
                                    if ($this->input->get('urutan', TRUE) == "3")
                                        echo "selected";
                                    ?>
                                            >Harga Min-Maks</option>
                                    <option value="4"
                                    <?php
                                    if ($this->input->get('urutan', TRUE) == "4")
                                        echo "selected";
                                    ?>>Harga Maks-Min</option>
                                    <option value="5"
                                    <?php
                                    if ($this->input->get('urutan', TRUE) == "5")
                                        echo "selected";
                                    ?>>Ukuran Besar ke Kecil</option>
                                    <option value="6"
                                    <?php
                                    if ($this->input->get('urutan', TRUE) == "6")
                                        echo "selected";
                                    ?>>Ukuran Kecil ke Besar</option>
                                </select>
                            </div>
                            <div class="span3 hasilperhalaman pull-right">
                                Hasil Perhalaman:
                                <select name="nitem" value="hasilperhalaman" class="select-block span1"
                                        onchange="this.form.submit()">
                                    <option value="10"
                                    <?php
                                    if ($this->input->get('nitem', TRUE) == "10")
                                        echo "selected";
                                    ?>>10</option>
                                    <option value="20"
                                    <?php
                                    if ($this->input->get('nitem', TRUE) == "20")
                                        echo "selected";
                                    ?>>20</option>
                                    <option value="30"
                                    <?php
                                    if ($this->input->get('nitem', TRUE) == "30")
                                        echo "selected";
                                    ?>>30</option>
                                    <option value="40"
                                    <?php
                                    if ($this->input->get('nitem', TRUE) == "40")
                                        echo "selected";
                                    ?>>40</option>
                                    <option value="50"
                                    <?php
                                    if ($this->input->get('nitem', TRUE) == "50")
                                        echo "selected";
                                    ?>>50</option>
                                </select>
                            </div>
                        </div>
                        <?php
                            foreach ($result as $value) {
                                ?>                            
                                <div class="span8 properti">
                                    <div class="span8 judulproperti">
                                        <h4><?php echo $value->nama_properti; ?></h4>
                                    </div>
                                    <div class="row">
                                        <div class="span2">
                                            <?php
                                                //echo $value->properti_id;
                                                $sql = "select * from media where media.properti_id = ?";
                                                $query = $this->db->query($sql, $value->properti_id);
                                                $data_output['properti']['picture'] = "";
                                                
                                                if ($query->first_row()) {
                                                    $pic_prop = $query->row();
                                                    $data_output['properti']['picture'] = $pic_prop->url;
                                                }
                                                $numpicprop = $query->num_rows();
                                                $url = "";
                                                if ($data_output['properti']['picture'] != "") {
                                                     $url = base_url() . 'pictures/properti/' . $data_output['properti']['picture'];
                                                } else {
                                                     $url = base_url() . 'assets/img/rumah_default3.png';
                                                }
                                            ?>
                                            <img src="<?php echo $url?>" class="img-polaroid">
                                            <p class="palette-paragraph jmlfoto"><?php echo $numpicprop;?> Foto</p>
                                            <a href="
                                            <?php echo site_url('listing/detail/' . $value->properti_id); ?>
                                               " class="btn btn-lihatdetail">Lihat Detail</a>
                                            <!-- <a href="#peta" data-toggle="modal" class="btn btn-peta">Peta</a> -->
                                            <!-- <div id="controls"> -->
                                                <!-- <input type="button" class="btn btn-peta" name="showMap" value="PETA" id="showMap" /> -->
                                            <!-- <a class="btn btn-peta" id="showMap">Peta</a> -->
                                            <!-- </div> --> 
                                        </div>
                                        <div class="span4">
                                            <h4>Rp.
                                                <?php
                                                echo number_format($value->harga);
                                                ?>
                                            </h4>
                                            <p> 
                                                <?php
                                                echo $value->nama . " ";
                                                if ($value->sewa_beli == 1) {
                                                    echo "dijual";
                                                } else {
                                                    echo "disewakan";
                                                }
                                                ?>
                                                <br/>
                                            <div class="row">
                                                <div class="span2">
                                                    <p class="palette-paragraph">
                                                        Kamar Mandi:
                                                        <?php echo $value->jml_kmr_mandi; ?> <br />
                                                        Kamar Tidur:
                                                        <?php echo $value->jml_kmr_tidur; ?> <br />
                                                        <?php echo $value->tipe_furnitur ?>
                                                    </p>

                                                </div>
                                                <div class="span2">
                                                    <p class="palette-paragraph">
                                                        Luas Bangunan:
                                                        <?php echo $value->luas_bangunan; ?>
                                                        m<sup>2</sup> <br/>
                                                        Luas Tanah:
                                                        <?php echo $value->luas_tanah; ?>
                                                        m<sup>2</sup> <br/>
                                                        Sertifikat:
                                                        <?php echo $value->nama_sertifikat; ?>
                                                    </p>
                                                </div>
                                            </div>
                                            <p class="palette-paragraph">( Diiklankan tanggal
                                                <?php
                                                echo substr($value->tgl_update, 8, 2) . " " .
                                                $bulan[substr($value->tgl_update, 5, 2)] . " " .
                                                substr($value->tgl_update, 0, 4);
                                                ?>
                                                )</p>                    
                                            </p>
                                        </div>
                                        <div class="span2 infoagen">
                                            <div class="span2 fotoagen">
                                                <?php
                                                //echo $value->user_id;
                                                $sql = "select * from media where media.user_id = ?";
                                                $query = $this->db->query($sql, $value->user_id);
                                                $data_output['agen']['picture'] = "";
                                                if ($query->num_rows() == 1) {
                                                    $pic_agen = $query->row();
                                                    $data_output['agen']['picture'] = $pic_agen->url;
                                                }

                                                $url = "";
                                                if ($data_output['agen']['picture'] != "") {
                                                    $url = base_url() . 'pictures/user/thumb/' . $data_output['agen']['picture'];
                                                } else {
                                                    $url = base_url() . 'assets/img/default_profile.png';
                                                }
                                                ?>
                                                <img src="<?php echo $url; ?>" class="img-polaroid" width="70px" height="70px">

                                            </div>
                                            <p class="palette-paragraph">
                                                <?php echo $value->nama_depan . " " . $value->nama_belakang; ?>
                                                <br />
                                                HP : 
                                                <?php echo $value->no_hp; ?>
                                                <br />
                                                BB :
                                                <?php echo $value->pin_bb; ?>
                                                <br />
                                            </p>
                                            <div class="span2 hubungiagen">
                                                <a href="#hubungiAgen" data-toggle="modal"
                                                   class="btn btn-small btn-block btn-primary">Hubungi Agen</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <?php
                            }
                        } else {
                            echo "<h3>Hasil pencarian tidak ditemukan...</h3>";
                        }
                        ?>
                        <center>
                            <div class="paginasi">
                                <?php
                                echo $this->pagination->create_links();
                                ?>
                            </div>
                        </center>



<!-- <center>
<div class="pagination">
<ul>
<li class="previous"><a href="#fakelink" class="fui-arrow-left"></a></li>
<li class="active"><a href="#fakelink">1</a></li>
<li><a href="#fakelink">2</a></li>
<li><a href="#fakelink">3</a></li>
<li class="next"><a href="#fakelink" class="fui-arrow-right"></a></li>
</ul>
</div>
</center> -->

                    </div>
                </div>

            </div>
        </div>
    </div>
</form>

<div id="peta" class="span4 modal hide fade" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
        <h4 id="myModalLabel">Peta</h4>
    </div>
    <div class="modal-body">
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
    </div>
</div>
<div id="hubungiAgen" class="modal hide fade" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
        <h4 id="myModalLabel">Hubungi Agen</h4>
    </div>
    <form action="" id="input-form" class="form-horizontal">
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label" for="dihubungi">Saya ingin dihubungi,karena:</label>
                <div class="controls">
                    <select name="dihubungi" id="dihubungi">
                        <option value="0">Saya ingin melihat properti ini</option>
                        <option value="1">Saya ingin informasi lebih lanjut</option>
                        <option value="2">Saya mempunyai tempat serupa utk dijual/disewa</option>
                    </select>
                </div>           
            </div>       
            <div class="control-group">
                <label class="control-label" for="titel">Titel:</label>
                <div class="controls">
                    <select name="titel" id="titel" class="span3">
                        <option value="0">Bapak</option>
                        <option value="1">Ibu</option>
                        <option value="2">Sdr/i</option>
                    </select>
                </div> 
            </div>
            <div class="control-group">
                  <label class="control-label" for="name">Nama Anda</label>
                  <div class="controls">
                    <input type="text" class="input-xlarge" name="name" id="name">
                  </div>
            </div>
            <div class="control-group">
                  <label class="control-label" for="name">Alamat E-mail</label>
                  <div class="controls">
                    <input type="text" class="input-xlarge" name="email" id="email">
                  </div>
            </div>
            <div class="control-group">
                  <label class="control-label" for="tel">No. HP</label>
                  <div class="controls">
                    <input type="tel" class="input-xlarge" name="tel" id="tel">
                  </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="hubungisaya">Hubungi saya via</label>
                <div class="controls">
                    <select name="hubungisaya" id="hubungisaya" class="select-block">
                        <option value="0">Telepon atau E-mail</option>
                        <option value="1">Hanya Telepon</option>
                        <option value="2">Hanya E-mail</option>
                    </select>
                </div> 
            </div>
            <div class="control-group">
                <label class="control-label" for="hubungisaya">Hubungi saya</label>
                <div class="controls">
                    <select name="hubungisaya" id="hubungisaya" class="select-block">
                        <option value="0">Kapan Saja</option>
                        <option value="1">Pagi Hari</option>
                        <option value="2">Sore Hari</option>
                        <option value="3">Malam Hari</option>
                        <option value="4">Akhir Minggu</option>
                    </select>
                </div> 
            </div>
            <label class="checkbox" for="checkbox_berlangganan">
                <input type="checkbox" name="mau_proyek" for="mau_proyek" value="1" id="checkbox_berlangganan" data-toggle="checkbox">
                Berlangganan untuk menerima proyek baru via email
            </label>
            <label class="checkbox" for="checkbox_info_baru">
                <input type="checkbox" name="mau_info" for="mau_info" value="1" id="checkbox_info_baru" data-toggle="checkbox">
                Beritahu saya tentang artyproperty.com informasi terbaru dan tawaran agency
            </label>
            <div class="span4 offset2">
                <input type="submit" name="SUBMIT"  class="btn btn-primary btn-large span3" value="Submit" />
            </div>
        </div>
    </form>
</div>
<!-- Modal -->
        <div id="foto_properti" class="span5 modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
                <h4 id="myModalLabel">Galeri Properti</h4>
            </div>
            <div class="modal-body">
                <div id="carousel-example-generic" class="carousel slide">
                  <!-- Wrapper for slides -->
                  <div class="carousel-inner">
                    <div class="item active">
                      <img src="<?php echo base_url(); ?>assets/img/images1.jpg" width="525px">
                    </div>
                    <div class="item">
                      <img src="<?php echo base_url(); ?>assets/img/images2.jpg" width="525px">
                    </div>
                    <div class="item">
                      <img src="<?php echo base_url(); ?>assets/img/images3.jpg" width="525px">
                    </div>
                  </div>

                  <!-- Controls -->
                  <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
                    <span class="icon-prev"></span>
                  </a>
                  <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
                    <span class="icon-next"></span>
                  </a>
                </div>

            </div>
        </div>
<script type="text/javascript">
$(function() {
    $('.carousel').carousel({
        interval: 3000
    });
  });
</script>